//
//  SYP_ManagerViewController.m
//  wind
//
//  Created by SYP on 16/1/14.
//  Copyright © 2016年 李金明. All rights reserved.
//

#import "SYP_ManagerViewController.h"
#import "LJMMain_ViewController.h"
#import "SYP_LeftViewController.h"

@interface SYP_ManagerViewController ()

@property (nonatomic, retain) LJMMain_ViewController *mainVC;
@property (nonatomic, retain) SYP_LeftViewController *leftVC;
@end

@implementation SYP_ManagerViewController

- (void)dealloc
{
    [_mainVC release];
    [_leftVC release];
    [super dealloc];
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    
    UIImageView *imageV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"playbackground"]];
    [self.view addSubview:imageV];
    imageV.frame = self.view.frame;
    
    
    
    
#pragma 左侧界面
    [self.leftVC = [SYP_LeftViewController alloc] init];
    self.leftVC.view.frame = CGRectMake(-SCREEN_WIDTH / 4 * 3, 0, SCREEN_WIDTH / 4 * 3, SCREEN_HEIGHT);
    [self addChildViewController: self.leftVC];
    [self.view addSubview:self.leftVC.view];
    //    [_leftVC release];
    
#pragma 主界面
    self.mainVC = [[LJMMain_ViewController alloc] init];
    [self.mainVC sendBlock:^(NSInteger n) {
        
        if (1 == n) {
            [UIView animateWithDuration:0.5 animations:^{
                
                self.mainVC.view.frame = CGRectMake(SCREEN_WIDTH / 4 * 3, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
                self.leftVC.view.frame = CGRectMake(0, 0, SCREEN_WIDTH / 4 * 3, SCREEN_HEIGHT);
                
            }];
        } else {
            
            
            [UIView animateWithDuration:0.5 animations:^{
                
                self.mainVC.view.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
                self.leftVC.view.frame = CGRectMake(-SCREEN_WIDTH / 4 * 3, 0, SCREEN_WIDTH / 4 * 3, SCREEN_HEIGHT);
                
            }];
        }
    }];
    self.mainVC = (LJMMain_ViewController *)[[UINavigationController alloc] initWithRootViewController:self.mainVC];
    self.mainVC.view.frame = self.view.frame;
    [self addChildViewController:self.mainVC];
    [self.view addSubview:self.mainVC.view];
//    [_mainVC release];
    

    
}

#pragma 抽屉的跳转
- (void)leftJumpPage
{
    NSLog(@"MAIN: 抽屉");
    
    [UIView animateWithDuration:0.5 animations:^{
        
        self.mainVC.view.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
        self.leftVC.view.frame = CGRectMake(-SCREEN_WIDTH / 4 * 3, 0, SCREEN_WIDTH / 4 * 3, SCREEN_HEIGHT);
        
    }];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
#pragma 用于禁止屏幕的旋转
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    
    return (toInterfaceOrientation == UIInterfaceOrientationPortrait);
    
}

- (BOOL)shouldAutorotate

{
    
    return NO;
    
}

- (NSUInteger)supportedInterfaceOrientations

{
    
    return UIInterfaceOrientationMaskPortrait;//只支持这一个方向(正常的方向)
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
